package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.service.RawMaterialArrivalRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "原料到货详情记录")
@RequestMapping("/record")
public class RawMaterialArrivalRecordController {

    @Autowired
    RawMaterialArrivalRecordService rawMaterialArrivalRecordService;

    @ApiOperation(value = "获取详情信息")
    @GetMapping("/info")
    public ResultBean getInfo(){
        List list=rawMaterialArrivalRecordService.getAll();
        return R.success("查询成功",list);
    }

    @PutMapping("/change")
    @ApiOperation(value = "修改原料到货信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "arrivalNum",value = "到货数量"),
            @ApiImplicitParam(name = "note",value = "备注"),
            @ApiImplicitParam(name = "storeAreaId",value = "卸货库区")
    })
    public ResultBean changeRawMaterialArrivalRecord(int id,int arrivalNum, String note, Integer storeAreaId){
        int res=rawMaterialArrivalRecordService.changeRawMaterialArrivalRecord(id, arrivalNum, note, storeAreaId);
        return res==1?R.success("修改成功"):R.fail("修改失败");
    }
}
